
import { Main } from "../../Main";
import StateBase from "../StateBase";
const Add = 1000;
const Max = 10000;
const Reduce = 1800;
export default class LastRecruitStartState extends StateBase {
    private _mainCom: Main;
    private _timer: number = 0;
    private _isFull: boolean = false;
    begin(preState: number): void {
        super.begin(preState);
        //console.log('LastRecruitStartState state--begin');
        this._mainCom = this.getUserData() as Main;
        if (!this._mainCom) {
            return;
        }
        const p = Math.min(Max, Add / Max);
        this._mainCom.progress.progress += p;
        if (this._mainCom.progress.progress >= 1 && !this._isFull) {
            this._isFull = true;
            this._mainCom.gameOver();
        }

    }

    end(nextState: number): void {
        super.end(nextState);
        // console.log('LastRecruitStartState state--end');
    }

    public tick(dt: number): void {
        if (!this._mainCom) {
            return;
        }
        if (this._isFull) {
            return;
        }
        const curProgress = this._mainCom.progress.progress;
        const p = Math.max(0, curProgress - dt * Reduce / Max);
        this._mainCom.progress.progress = p;
    }
}
